import {ModalForm, ProDescriptions} from '@ant-design/pro-components';
import React from "react";
import NotRealizeNotification from "@/pages/New/components/projectOverview/notRealizeNotification";

interface Project {
  companyJia: string,
  companyYi: string,
  contract: string,
  contractTime: [string, string],
  department: string,
  mangerName: string,
  projectName: string,
  projectType: string,
  isSupervise: string
};

interface Props {
  project: Project
}

interface RecentProjectsProps {
  project: Project; // 根据实际情况决定是否设置为必填项，默认为可选
}

const BasicCircumstances: React.FC<Props> = ({project}) => {
  return (
    <ProDescriptions
      title={project.projectName}
      dataSource={{
        companyJia: project.companyJia,
        companyYi: project.companyYi,
        contract: project.contract,
        dateStart: project.contractTime[0],
        dateEnd: project.contractTime[1],
        isSupervise: project.isSupervise,
        type: project.projectType,

      }}
      columns={[
        {
          title: '甲方公司',
          key: 'companyJia',
          dataIndex: 'companyJia',
          ellipsis: true,
          copyable: true,
        },
        {
          title: '乙方公司',
          key: 'companyYi',
          dataIndex: 'companyYi',
          ellipsis: true,
          copyable: true,
        },
        {
          title: '监管状态',
          key: 'isSupervise',
          dataIndex: 'isSupervise',
          valueType: 'select',
          valueEnum: {
            yes: {
              text: '监管中',
              status: 'Warning',
            },
            no: {
              text: '未监管',
              status: 'Default',
            },
          },
        },
        {
          title: '合同编号',
          key: 'contract',
          dataIndex: 'contract',
          valueType: 'text',
        },
        {
          title: '合同开始时期',
          key: 'dateStart',
          dataIndex: 'dateStart',
          valueType: 'date',
        },
        {
          title: '合同结束时期',
          key: 'dateEnd',
          dataIndex: 'dateEnd',
          valueType: 'date',
        },
        {
          title: '项目种类',
          key: 'type',
          dataIndex: 'type',
        },
      ]}
    >
      <ProDescriptions.Item label="操作">
        <NotRealizeNotification/>
      </ProDescriptions.Item>
    </ProDescriptions>
  );
};

const LearnMore: React.FC<RecentProjectsProps> = (props) => {
  const project = props.project; // 防止未传入 recentProjects 时导致报错

  return (
    <ModalForm<{
      name: string;
      company: string;
    }>
      trigger={
        <p>
          了解详情
        </p>
      }
      submitter={false}
    >
      <BasicCircumstances project={project}/>
    </ModalForm>
  );
};

export default LearnMore;
